(function () {
    window.Racket = class Racket {
        constructor () {
            this.x = 500
            this.y = game.canvas.height - 20
            this.width = 96
            this.height = 16
            this.bindEventListener()
        }
        render () {
            game.context.drawImage(game.images.racket, this.x, this.y, 96, 16)
        }
        bindEventListener () {
            game.canvas.addEventListener('mousemove',(e) => {
                this.x = e.offsetX
                if (this.x + 96 >= game.canvas.width) {
                    this.x = game.canvas.width - 96
                }
            })
            game.canvas.addEventListener('mousedown',(e) => {
                game.state = 1
            })
        }
    }
})()